/**
 * 文件描述：操作权限设置
 * 创建时间：2023/10/16 11:28
 * 创建人：二
 */
import store from '@/store'

export default {
	inserted(el, binding) {
		const { value } = binding;
		const { permissions, allPermission } = store.getters;
		if (value && value instanceof Array && value.length > 0) {

			const hasPermissions = permissions.some(permission => {
				return allPermission === permission || value.includes(permission)
			})

			if (!hasPermissions) {
				el.parentNode && el.parentNode.removeChild(el)
			}
		} else {
			throw new Error(`请设置操作权限标签值`)
		}
	}
}
